<template>
  <div class="main">
    <main v-for="(item, index) in renderTuan" :key="index">
      <div class="left">
        <img :src="item.picture" alt="" />
      </div>
      <div class="content">
        <h1>{{ item.name }}</h1>
        <footer>
          <div class="price">
            <div>爆爆团价</div>
            <p>￥{{ item.min_price }}</p>
            <span>￥{{ item.min_price * 5 }}</span>
          </div>
          <div class="btn">
            <button @click="chenbox(item)">
              {{ item.status == 0 ? "已抢" : "马上抢" }}
            </button>
            <span>已售{{ item.month_saled }}份</span>
          </div>
        </footer>
      </div>
    </main>
  </div>
</template>

<script>
import { waimai_tuan } from "../../api/index";
export default {
  data() {
    return {
       num: 0,
      renderTuan: null,
    };
  },
  mounted() {
    // 组件挂载完成，发送请求数据
    waimai_tuan({ status: 1 }).then((res) => {
      this.renderTuan = res.data.list;
    });
  },
    methods: {
    chenbox(item) {
      if (item.status == 1) {
        item.status = 0;
      }
    },
    }
};
</script>

<style lang="css" scoped>
.main main {
  height: 100px;
  border-radius: 10px;
  background-color: white;
  margin: 10px;
  display: flex;
  justify-content: space-between;
  border: 1px solid gray;
  padding: 10px;
  align-items: center;
}
.main main .left {
  width: 35%;
  margin-left: 10px;
}
.main main .left img {
  width: 100%;
}
.main main .content {
  width: 60%;
}
.main main .content h1 {
  font-size: 16px;
  margin-bottom: 10px;
  margin-top: 10px;
}
.main main .content footer {
  display: flex;
  padding: 10px;
  justify-content: space-between;
}
.main main .content footer .price {
  width: 60px;
}
.main main .content footer .price div {
  font-size: 14px;
  color: red;
}
.main main .content footer .price p {
  font-size: 18px;
  color: red;
}
.main main .content footer .price span {
  font-size: 12px;
  color: gray;
  text-decoration: line-through;
}
.main main .content footer .btn {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 0;
}
.main main .content footer .btn button {
  width: 70px;
  height: 30px;
  background-color: red;
  border-radius: 20px;
  border: none;
  color: white;
}
.main main .content footer .btn span {
  font-size: 12px;
  color: red;
}
</style>